<ui:component xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a="https://ajax4jsf.dev.java.net/ajax"
	xmlns:rich="http://richfaces.ajax4jsf.org/rich">

	<ul class="txt11">
		<f:subview
			rendered="#{param.idObjekta != null and identity.loggedIn and (identity.username == objektDetails.autor.username or identity.hasRole('1') or identity.hasRole('3') or identity.hasRole('4'))}">
			<li title="#{messages['label.objekt.input.button.edit']}"><s:link
				action="#{objektSuggest.izmijeniObjekt('backToObjekt')}"
				id="lnkEdit">
				<f:param name="idObjekta" value="#{param.idObjekta}" />
				<h:graphicImage value="/resources/images/icons/document--pencil.png" />
			</s:link></li>
		</f:subview>
		<!-- Ovaj dio ukljuci nakon deploya -->
		<f:subview
			rendered="#{param.idObjekta != null and false}" id="rdView">
			<li title="#{messages['label.contact.type.reservationInfo']}"><a href="#pnlReservation"
				id="lnkFreePeriod" title="#{messages['label.contact.type.reservationInfo']}" class="boxy">
				<h:graphicImage value="/resources/images/icons/calendar-list.png" /></a>
				<div id="pnlReservation" class="popup">
					<h:form id="formReservation" styleClass="modalForm" prependId="false">
						<a:region renderRegionOnly="true">
						<a:outputPanel ajaxRendered="true">
							<rich:messages globalOnly="true" infoClass="info"
								errorClass="error" />
							<h:panelGrid columns="2">
								<h:outputLabel value="#{messages['label.contact.name']}*" />
								<s:decorate id="imeDecoration"
									template="/templates/editNoLabel.xhtml">
									<h:inputText value="#{objektReservation.name}"
										styleClass="field" required="true">
									</h:inputText>
								</s:decorate>
								<h:outputLabel value="#{messages['label.contact.email']}*" />
								<s:decorate id="feedbackEmailDecoration"
									template="/templates/editNoLabel.xhtml">
									<h:inputText id="feedbackEmail"
										value="#{objektReservation.email}" styleClass="field"
										required="true" validator="#{feedbackAction.checkEmail}">
			
									</h:inputText>
								</s:decorate>
								
								<rich:calendar id="rdCalendar" dataModel="#{objektReservation.dataModel}" datePattern="dd.MM.yyyy" mode="ajax" popup="false" showApplyButton="false" ondateselected="adjustValues(event.rich.date);return false;"/>
								<h:panelGrid columns="1">
								<s:decorate template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['label.contact.date.start']}</ui:define>
								<h:inputText id="rdFrom" value="#{objektReservation.dateArrival}" required="true"/>
								</s:decorate>
								<s:decorate template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['label.contact.date.stop']}</ui:define>
								<h:inputText id="rdTo" value="#{objektReservation.dateDeparture}" required="true"/>
								</s:decorate>
								<h:inputHidden id="rdState" value="0" />
								<script type="javaScript"><!--
								function adjustValues(value){
									calendar = $('rdView:rdCalendar').component;
									status = document.getElementById('rdView:rdState').getValue();
									varStatus = document.getElementById('rdView:rdState');
									varFrom = document.getElementById('rdView:j_id112:rdFrom');
									varTo = document.getElementById('rdView:j_id125:rdTo');
									if(0==status){
										varFrom.setValue(calendar.getSelectedDateString());
										varStatus.setValue(1);
									}else if(1==status){
										varTo.setValue(calendar.getSelectedDateString());
										for(var j=calendar.firstDateIndex;j<calendar.days.length;){
											if(gte(calendar.days[j].data,varFrom.getValue()) && lte(calendar.days[j].data,varTo.getValue())){
												class = document.getElementById(calendar.days[j].elementId).className;
												document.getElementById(calendar.days[j].elementId).className = class+ " rich-calendar-select";
							
											}else if(gte(calendar.days[j].data,varTo.getValue())){
												//calendar.render();
												break;
											}
											j++;
											
										}
										varStatus.setValue(2);
									}else if(2==status){
										calendar.render();
										varFrom.setValue(calendar.getSelectedDateString());
										varTo.setValue("");
										varStatus.setValue(1);
									};
								}
								function gte(d1,d2){
									return (getIso(d1)*1)>=(getIso(d2)*1);
								}
								function lte(d1,d2){
									return (getIso(d1)*1)<=(getIso(d2)*1);
								}
								function getIso(d){
									iso = "";
									tmp = "";
									for(i=0;i<d.length;i++){
										if(d.charAt(i)=='.'){
											iso=tmp+iso;
											tmp="";
										}else{
											tmp+=d.charAt(i);
										}
									}
									iso=tmp+iso;
									return iso;
								}


-->
								</script>
								</h:panelGrid>
								<s:decorate template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['label.contact.gust.age.adult']}</ui:define>
								<h:inputText value="#{objektReservation.adultAgeCnt}" styleClass="field"
												 required="true">
												<f:convertNumber type="number" /> 
								</h:inputText>
								</s:decorate>
								<s:decorate template="/templates/edit.xhtml">
									<ui:define name="label">#{messages['label.contact.gust.age.child']}</ui:define>
									<h:inputText value="#{objektReservation.childAgeCnt}" styleClass="field">
										<f:convertNumber type="number" />
									</h:inputText>	
								</s:decorate>					
							</h:panelGrid>
							<h:panelGroup>
								<s:decorate template="/templates/edit.xhtml">
									<ui:define name="label">#{messages['message.objekt.contact.extranote']}</ui:define>
									<h:inputTextarea value="#{objektReservation.extraNote}"
										styleClass="text">
			
									</h:inputTextarea>
								</s:decorate>
							</h:panelGroup>
			
							<s:div>
								<a:commandButton value="#{messages['label.contact.button.send']}"
									action="#{objektReservation.rezervirajSmjestaj('backToObjekt')}" reRender="form">
									<f:param name="idObjekta" value="#{param.idObjekta}" />
								</a:commandButton>
							</s:div>
							</a:outputPanel>
						</a:region>
					</h:form>				
				</div>	
			</li>
		</f:subview>
		<f:subview rendered="#{param.idObjekta != null}">
			<li title="#{messages['label.contact.type.reservationInfo']}"><a href="#pnlFreePeriod"
				id="lnkFreePeriod" title="#{messages['label.contact.type.reservationInfo']}" class="boxy">
				<h:graphicImage value="/resources/images/icons/calendar-list.png" /></a>
				<div id="pnlFreePeriod" class="popup">
					<h:form id="form" styleClass="modalForm">
						<a:region renderRegionOnly="true">
						<a:outputPanel ajaxRendered="true">
							<rich:messages globalOnly="true" infoClass="info"
								errorClass="error" />
							<h:panelGrid columns="2">
								<h:outputLabel value="#{messages['label.contact.name']}*" />
								<s:decorate id="imeDecoration"
									template="/templates/editNoLabel.xhtml">
									<h:inputText id="ime" value="#{feedbackAction.feedbackName}"
										styleClass="field" required="true">
			
									</h:inputText>
								</s:decorate>
								<h:outputLabel value="#{messages['label.contact.email']}*" />
								<s:decorate id="feedbackEmailDecoration"
									template="/templates/editNoLabel.xhtml">
									<h:inputText id="feedbackEmail"
										value="#{feedbackAction.feedbackEmail}" styleClass="field"
										required="true" validator="#{feedbackAction.checkEmail}">
			
									</h:inputText>
								</s:decorate>
								<h:outputLabel value="#{messages['label.contact.date.start']}" />
								<rich:calendar value="#{feedbackAction.feedbackDateArrival}"
									popup="true" showApplyButton="false" />
								<h:outputLabel value="#{messages['label.contact.date.stop']}" />
								<rich:calendar value="#{feedbackAction.feedbackDateDeparture}"
									popup="true" showApplyButton="false" />
								<h:outputLabel value="#{messages['label.contact.gust.age.adult']}" />
														<h:selectOneMenu styleClass="field"
												value="#{feedbackAction.feedbackAdultAgeCnt}">
												<f:selectItem itemLabel="#{messages['label.choose']}"
													itemValue="" />
												<f:selectItem itemLabel="1" itemValue="1" />
												<f:selectItem itemLabel="2" itemValue="2" />
												<f:selectItem itemLabel="3" itemValue="3" />
												<f:selectItem itemLabel="4" itemValue="4" />
												<f:selectItem itemLabel="5" itemValue="5" />
												<f:selectItem itemLabel="6" itemValue="6" />
												<f:selectItem itemLabel="7" itemValue="7" />
												<f:selectItem itemLabel="8" itemValue="8" />
												<f:selectItem itemLabel="9" itemValue="9" />
												<f:selectItem itemLabel="10" itemValue="10" />
												<f:selectItem itemLabel="15" itemValue="15" />
												<f:selectItem itemLabel="20" itemValue="20" />
												<f:selectItem itemLabel="50" itemValue="50" />
											</h:selectOneMenu>
								<h:outputLabel value="#{messages['label.contact.gust.age.child']}" />
														<h:selectOneMenu styleClass="field"
												value="#{feedbackAction.feedbackChildAgeCnt}">
												<f:selectItem itemLabel="#{messages['label.choose']}"
													itemValue="" />
												<f:selectItem itemLabel="1" itemValue="1" />
												<f:selectItem itemLabel="2" itemValue="2" />
												<f:selectItem itemLabel="3" itemValue="3" />
												<f:selectItem itemLabel="4" itemValue="4" />
												<f:selectItem itemLabel="5" itemValue="5" />
												<f:selectItem itemLabel="6" itemValue="6" />
												<f:selectItem itemLabel="7" itemValue="7" />
												<f:selectItem itemLabel="8" itemValue="8" />
												<f:selectItem itemLabel="9" itemValue="9" />
												<f:selectItem itemLabel="10" itemValue="10" />
												<f:selectItem itemLabel="15" itemValue="15" />
												<f:selectItem itemLabel="20" itemValue="20" />
												<f:selectItem itemLabel="50" itemValue="50" />
											</h:selectOneMenu>
							</h:panelGrid>
							<h:panelGroup>
								<s:decorate id="textDecoration" template="/templates/edit.xhtml">
									<ui:define name="label">#{messages['message.objekt.contact.extranote']}</ui:define>
									<h:inputTextarea value="#{feedbackAction.feedbackMessage}"
										styleClass="text">
			
									</h:inputTextarea>
								</s:decorate>
							</h:panelGroup>
			
							<s:div>
								<a:commandButton value="#{messages['label.contact.button.send']}"
									action="#{feedbackAction.registerFeedback}" reRender="form">
									<f:param name="idObjekta" value="#{param.idObjekta}" />
									<a:actionparam value="ri"
										assignTo="#{feedbackAction.feedbackType}"></a:actionparam>
								</a:commandButton>
							</s:div>
							</a:outputPanel>
						</a:region>
					</h:form>				
				</div>	
			</li>
		</f:subview>
		<f:subview rendered="#{param.idObjekta != null}">
			<li title="#{messages['label.contact.type.info']}"><a href="#pnlInfo"
				id="lnkInfo" title="#{messages['label.contact.type.info']}" class="boxy">
				<h:graphicImage value="/resources/images/icons/information.png" /> </a>
				<div id="pnlInfo" class="popup">
					<h:form id="form" styleClass="modalForm">
						<a:region renderRegionOnly="true">
						<a:outputPanel ajaxRendered="true">
							<rich:messages globalOnly="true" infoClass="info"
								errorClass="error" />
							<h:panelGrid columns="2">
								<h:outputLabel value="#{messages['label.contact.name']}*" />
								<s:decorate id="imeDecoration"
									template="/templates/editNoLabel.xhtml">
									<h:inputText id="ime" value="#{feedbackAction.feedbackName}"
										styleClass="field" required="true">
			
									</h:inputText>
								</s:decorate>				
								<h:outputLabel value="#{messages['label.contact.email']}*" />
								<s:decorate id="feedbackEmailDecoration"
									template="/templates/editNoLabel.xhtml">
									<h:inputText id="feedbackEmail"
										value="#{feedbackAction.feedbackEmail}" styleClass="field"
										required="true" validator="#{feedbackAction.checkEmail}">
										<a:support event="onblur" reRender="feedbackEmailDecoration"
											bypassUpdates="true">
											<f:param name="idObjekta" value="#{param.idObjekta}" />
											</a:support>
									</h:inputText>
								</s:decorate>
							</h:panelGrid>
							<h:panelGroup>
								<s:decorate id="textDecoration" template="/templates/edit.xhtml">
									<ui:define name="label">#{messages['message.objekt.contact.extranote']}</ui:define>
									<h:inputTextarea value="#{feedbackAction.feedbackMessage}"
										styleClass="text">
			
									</h:inputTextarea>
								</s:decorate>
							</h:panelGroup>
			
							<s:div>
								<a:commandButton value="#{messages['label.contact.button.send']}"
									action="#{feedbackAction.registerFeedback}">
									<f:param name="idObjekta" value="#{param.idObjekta}" />
									<a:actionparam value="i" assignTo="#{feedbackAction.feedbackType}"></a:actionparam>
								</a:commandButton>
							</s:div>
							</a:outputPanel>
						</a:region>
					</h:form>				
				</div>	
			</li>
		</f:subview>
		<f:subview rendered="#{param.idObjekta != null}">
			<li title="#{messages['label.save.to.favorites']}">
			<h:form> 
				<a:region renderRegionOnly="true" id="favoritLinkForm">
					<a:outputPanel ajaxRendered="true">
						<a:commandLink id="favoritesLink1"
							action="#{objektDetailsAction.addToFavorites}"
							rendered="#{objektDetailsAction.favorit == false}">
							<f:param name="idObjekta" value="#{param.idObjekta}" />
							<h:graphicImage value="/resources/images/icons/star--plus.png" />
						</a:commandLink>
						<a:commandLink id="favoritesLink2"
							action="#{objektDetailsAction.removeFromFavorites}"
							rendered="#{objektDetailsAction.favorit == true}">
							<f:param name="idObjekta" value="#{param.idObjekta}" />
							<h:graphicImage value="/resources/images/icons/star--minus.png" />
						</a:commandLink>
					</a:outputPanel>
				</a:region>
			</h:form></li>
		</f:subview>
		<f:subview rendered="#{param.idObjekta != null}">
			<li title="#{messages['label.contact.type.emailtofriend']}" ><a href="#pnlEmail"
				id="lnkEmail" title="#{messages['label.contact.type.emailtofriend']}" class="boxy"> <h:graphicImage value="/resources/images/icons/mail.png" />
			</a>
			<div id="pnlEmail" class="popup">
				<h:form id="form" styleClass="modalForm">
					<a:region renderRegionOnly="true">
					<a:outputPanel ajaxRendered="true">
						<rich:messages globalOnly="true" infoClass="info"
							errorClass="error" />
						<h:panelGrid columns="2">
							<h:outputLabel value="#{messages['label.contact.name']}*" />
							<s:decorate id="imeDecoration"
								template="/templates/editNoLabel.xhtml">
								<h:inputText id="ime" value="#{feedbackAction.feedbackName}"
									styleClass="field" required="true">
		
								</h:inputText>
								</s:decorate>
							<h:outputLabel value="#{messages['label.contact.email']}*" />
							<s:decorate id="feedbackEmailDecoration"
								template="/templates/editNoLabel.xhtml">
								<h:inputText id="feedbackEmail"
									value="#{feedbackAction.feedbackEmail}" styleClass="field"
									required="true" validator="#{feedbackAction.checkEmail}">
			
								</h:inputText>
							</s:decorate>
							<h:outputLabel
								value="#{messages['message.objekt.contact.sendersfriendemail']}*" />
							<s:decorate id="feedbackFEmailDecoration"
								template="/templates/editNoLabel.xhtml">
								<h:inputText id="feedbackFEmail"
									value="#{feedbackAction.feedbackFriendEmail}" styleClass="field"
									validator="#{feedbackAction.checkEmail}" required="true">
		
								</h:inputText>
							</s:decorate>
						</h:panelGrid>
						<h:panelGroup>
							<s:decorate id="textDecoration" template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['message.objekt.contact.extranote']}</ui:define>
								<h:inputTextarea value="#{feedbackAction.feedbackMessage}"
									styleClass="text">
		
								</h:inputTextarea>
							</s:decorate>
						</h:panelGroup>
						<s:div>
							<a:commandButton value="#{messages['label.contact.button.send']}"
								action="#{feedbackAction.registerFeedback}">
								<f:param name="idObjekta" value="#{param.idObjekta}" />
								<a:actionparam value="o" assignTo="#{feedbackAction.feedbackType}"></a:actionparam>
							</a:commandButton>
						</s:div>
						</a:outputPanel>
					</a:region>
				</h:form>			
			</div>
			</li>
		</f:subview>
		<f:subview rendered="#{param.list != null}">
			<li title="#{messages['label.contact.type.emailtofriend']}"><a href="#pnlCompare"
				id="lnkComapre" class="boxy" title="#{messages['label.contact.type.emailtofriend']}"> 
				<h:graphicImage value="/resources/images/icons/mail.png" />
			</a>
				<div id="pnlCompare" class="popup">
					<h:form id="formCompareObject" styleClass="modalForm">
						<a:region renderRegionOnly="true">
							<a:outputPanel ajaxRendered="true">
								<rich:messages globalOnly="true" infoClass="info"
									errorClass="error" />
								<h:panelGrid columns="1" width="100%">
									<h:outputLabel value="#{messages['label.contact.name']}" />
									<s:decorate id="imeDecoration"
										template="/templates/editNoLabel.xhtml">
										<h:inputText id="ime" value="#{feedbackAction.feedbackName}"
											styleClass="field" required="true">
			
										</h:inputText>
									</s:decorate>
									<h:outputLabel value="#{messages['label.contact.email']}" />
									<s:decorate id="feedbackEmailDecoration"
										template="/templates/editNoLabel.xhtml">
										<h:inputText id="feedbackEmail"
											value="#{feedbackAction.feedbackEmail}" styleClass="field"
											required="true" validator="#{feedbackAction.checkEmail}">
			
										</h:inputText>
									</s:decorate>
									<h:outputLabel
										value="#{messages['message.objekt.contact.sendersfriendemail']}" />
									<s:decorate id="feedbackFEmailDecoration"
										template="/templates/editNoLabel.xhtml">
										<h:inputText id="feedbackFEmail"
											value="#{feedbackAction.feedbackFriendEmail}" styleClass="field"
											required="true" validator="#{feedbackAction.checkEmail}">
			
										</h:inputText>
									</s:decorate>
									<rich:separator />
									<s:decorate id="textDecoration" template="/templates/edit.xhtml">
										<ui:define name="label">#{messages['message.objekt.contact.extranote']}</ui:define>
										<h:inputTextarea value="#{feedbackAction.feedbackMessage}"
											styleClass="text">
										</h:inputTextarea>
									</s:decorate>
								</h:panelGrid>
								<s:div>
									<a:commandButton value="#{messages['label.contact.button.send']}"
										action="#{feedbackAction.sendComparison}"></a:commandButton>
								</s:div>
							</a:outputPanel>
						</a:region>
					</h:form>				
				</div>
			</li>
		</f:subview>
		<f:subview>
			<li title="#{messages['label.print.this.page']}"><h:outputLink
				id="winPrint" onclick="javascript:window.print();return false;"
				value="#">
				<h:graphicImage value="/resources/images/icons/printer.png" />
			</h:outputLink></li>
		</f:subview>
		<f:subview
			rendered="#{(review == null or review == true) and param.idTipaObjekta == null and (param.idObjekta != null or param.idMjesta != null or param.idOtoka != null or param.idParka != null)}">
			<li title="#{messages['label.write.review']}"><h:outputLink
				value="#reviews" id="commentLink">
				<h:graphicImage value="/resources/images/icons/comment_add.png" />
			</h:outputLink></li>
		</f:subview>
		<li title="#{messages['label.report_inaccurate_abuse_data']}" ><a href="#pnlAbuse"
			id="lnkAbuse" class="boxy" title="#{messages['label.report_inaccurate_abuse_data']}"> 
			<h:graphicImage value="/resources/images/icons/exclamation.png" /> </a>
			<div id="pnlAbuse" class="popup">		
				<h:form>
					<a:region renderRegionOnly="true">
						<a:outputPanel ajaxRendered="true">
							<h:messages globalOnly="true" infoClass="info"
								errorClass="error"></h:messages>
						</a:outputPanel>
						<h:panelGrid id="pg" columns="1" cellpadding="0" cellspacing="0"
							width="100%">
							<s:decorate id="imeDecoration" template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['label.contact.name']}</ui:define>
								<h:inputText id="ime" value="#{feedbackAction.feedbackName}"
									styleClass="field" required="true" size="30">
		
								</h:inputText>
							</s:decorate>
							<s:decorate id="feedbackEmailDecoration"
								template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['label.contact.email']}</ui:define>
								<h:inputText id="feedbackEmail" size="30"
									value="#{feedbackAction.feedbackEmail}" styleClass="field"
									required="true" validator="#{feedbackAction.checkEmail}">
		
								</h:inputText>
							</s:decorate>
							<s:decorate id="textDecoration" template="/templates/edit.xhtml">
								<ui:define name="label">#{messages['message.objekt.contact.extranote']}</ui:define>
								<h:inputTextarea value="#{feedbackAction.inaccurateMessage}"
									styleClass="text" required="true"> 
								</h:inputTextarea>
							</s:decorate>
						</h:panelGrid>
						<s:div>
							<a:commandButton reRender="pg"
								action="#{feedbackAction.sendInaccurateData()}"
								value="#{messages['label.submit']}">
							</a:commandButton>
						</s:div>
					</a:region>
				</h:form>
			</div>				
		</li>
	</ul>

	<script type="text/javascript">
		 jQuery(function() {
			 jQuery('li[title]').qtip({
				   position: {
				      corner: {
				         target: 'bottomMiddle',
				         tooltip: 'topMiddle'
				      }
				   },
				   style: { 
				      name: 'light',
				      border: {
				          width: 2,
				          radius: 4
				       },
				   	   tip: 'topMiddle'					      
				   }, 				   
				   show: 'mouseover',
				   hide: 'mouseout'
				});							
     	});

	     	     	
	</script>
</ui:component>